<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Michael Wetter">
   <TITLE>GenOpt Readme Note</TITLE>
   <LINK REL ="stylesheet" TYPE="text/css" HREF="../../documentation/jdoc/jstyle.css" TITLE="Style">
</HEAD>
<!-- ========================================================== -->
<BODY>
<H1>GenOpt Examples for Dymola</H1>
<P>
This directory contains example files that illustrate the use 
of GenOpt in conjunction with the  
Modelica modeling and simulation environment Dymola.
To run the example files, a license of Dymola is required, which 
may be obtained from 
<a href="http://www.dynasim.com">Dynasim</a>.
</p>
<p>
Prior to running the optimization, you may have to start
Dymola, open the file <code>ObjectiveFunction.mo</code> translate and simulate
the model. This should generate the files 
<code>dymosim.exe</code> (or <code>dymosim</code> on Linux), 
<code>dsin.txt</code> and other 
files that are not needed to run the example.
The model needs to be simulated once, as this adds the final time
of the simulation (which is stored in <code>ObjectiveFunction.mo</code>) to the
file <code>dsin.txt</code>.
The files <code>dymosim.exe</code> (or <code>dymosim</code> on Linux)
and <code>dsin.txt</code> need 
to be in the same directory as the file 
<code>ObjectiveFunction.mo</code>. If they are written to a different directory,
then you will need to change the working directory of Dymola.
This may be done from the Dymola simulation window by typing
<code>cd("path");</code> where <code>path</code> need to be replaced 
by the name of the path that contains the file <code>ObjectiveFunction.mo</code>.
</p>
<p>
To learn how to run the optimization, see the GenOpt manual and
the GenOpt <a href="../../readme.html">readme file</a>.
</p>
<p>
During the optimization, GenOpt will use the template file
<code>modelicaScheduleTemplate.txt</code> to write the file
<code>modelicaSchedule.txt</code>.
This file contains the values of the independent parameters and will
be read by <code>dymosim.exe</code> during the simulation.
At the end of the simulation, 
GenOpt will scan the file <code>dslog.txt</code> for
possible errors that may have occurred during the simulation.
If there were no errors, GenOpt will read the file
<code>result.txt</code> to obtain the objective function value.
This file has been written by <code>dymosim.exe</code>.
If the file <code>dslog.txt</code> contains error messages,
then GenOpt will stop.
</p>
<p>
The optimization finds a control sequence that minimizes the squared difference between measured temperature and setpoint temperature for the model shown below:
<img src="images/model.png">
</p>
<p>
The optimized control sequence looks as follows:<br>
<img src="images/optimalControlSequence.png">
<br>
This control sequence yields the temperature trajectory labeled "optimized" in the figure below. The figure also shows the outside temperature, the temperature trajectory that corresponds to the initial non-optimized control input (labeled "initial setting") and the temperature setpoint.<br>
<img src="images/temperatureTrajectory.png">
</p>
<p>
For further information, please consult the GenOpt manual 
and the Dymola manual.
</p>
<!-- ========================================================== -->
<DIV CLASS="FOOTER">
<P>
<HR WIDTH=100%>
Please send comments or questions to
Michael Wetter, LBNL, <A HREF="mailto:MWetter@lbl.gov">MWetter@lbl.gov</A>
<BR>
August 4, 2010.
</DIV>
</BODY>
</HTML>
